<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends MY_Controller
{
	protected $need_login = false;
		
	public function __construct()
	{
		
		parent::__construct();
	}
	
	
	public function index()
	{
		$this->loadView('login_view');
	}
	
	
	public function validate_credential()
	{
		$this->load->model('User_model');
		
		$user = $this->User_model->validate_credential();
		
		if ($user['is_logged_in'])
		{
			$this->session->set_userdata($user);
		}
		else
		{
			$this->session->unset_userdata($user);
		}
		
		redirect('dashboard', 'location');
	}
}
